package com.fr.base.core.util;

import java.io.Serializable;
import java.util.AbstractCollection;
import java.util.AbstractSet;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class ListMap
  implements Map, Cloneable, Serializable
{
  private static final int TYPE_KEY_SET = 0;
  private static final int TYPE_ENTRY_SET = 1;
  private static final int TYPE_VALUES = 2;
  private HashMap m_map = null;
  private ListSet m_list = null;
  private transient Set m_keySet = null;
  private transient Set m_entrySet = null;
  private transient Collection m_values = null;

  public ListMap()
  {
    this.m_map = new HashMap();
    this.m_list = new ListSet();
  }

  public ListMap(int paramInt)
  {
    this.m_map = new HashMap(paramInt);
    this.m_list = new ListSet(paramInt);
  }

  public ListMap(int paramInt, float paramFloat)
  {
    this.m_map = new HashMap(paramInt, paramFloat);
    this.m_list = new ListSet(paramInt);
  }

  public ListMap(Map paramMap)
  {
    if (paramMap == null)
    {
      this.m_map = new HashMap();
      this.m_list = new ListSet();
    }
    else
    {
      this.m_map = new HashMap(paramMap);
      this.m_list = new ListSet(paramMap.keySet());
    }
  }

  public Object put(Object paramObject1, Object paramObject2)
  {
    return put(-1, paramObject1, paramObject2);
  }

  public Object remove(Object paramObject)
  {
    this.m_list.remove(paramObject);
    return this.m_map.remove(paramObject);
  }

  public Set keySet()
  {
    if (this.m_keySet == null)
      this.m_keySet = new KeySet(this, null);
    return this.m_keySet;
  }

  public void clear()
  {
    this.m_list.clear();
    this.m_map.clear();
  }

  public Collection values()
  {
    if (this.m_values == null)
      this.m_values = new Values(this, null);
    return this.m_values;
  }

  public int hashCode()
  {
    return this.m_map.hashCode();
  }

  public boolean containsKey(Object paramObject)
  {
    return this.m_map.containsKey(paramObject);
  }

  public int size()
  {
    return this.m_map.size();
  }

  public Set entrySet()
  {
    if (this.m_entrySet == null)
      this.m_entrySet = new EntrySet(this, null);
    return this.m_entrySet;
  }

  public boolean containsValue(Object paramObject)
  {
    return this.m_map.containsValue(paramObject);
  }

  public void putAll(Map paramMap)
  {
    if (paramMap != null)
    {
      this.m_map.putAll(paramMap);
      this.m_list.addAll(paramMap.keySet());
    }
  }

  public boolean equals(Object paramObject)
  {
    boolean bool = false;
    if (paramObject instanceof ListMap)
    {
      ListMap localListMap = (ListMap)paramObject;
      bool = this.m_map.equals(localListMap.m_map);
    }
    return bool;
  }

  public boolean isEmpty()
  {
    return this.m_map.isEmpty();
  }

  public Object get(Object paramObject)
  {
    return this.m_map.get(paramObject);
  }

  public Object put(int paramInt, Object paramObject1, Object paramObject2)
  {
    if (paramInt != -1)
    {
      localObject = this.m_list.get(paramInt);
      this.m_map.remove(localObject);
      this.m_list.remove(paramInt);
    }
    Object localObject = this.m_map.put(paramObject1, paramObject2);
    if (paramInt == -1)
      this.m_list.add(paramObject1);
    else
      this.m_list.add(paramInt, paramObject1);
    return localObject;
  }

  public Object getByIndex(int paramInt)
  {
    return get(this.m_list.get(paramInt));
  }

  public Object remove(int paramInt)
  {
    return remove(this.m_list.get(paramInt));
  }

  public int indexOf(Object paramObject)
  {
    return this.m_list.indexOf(paramObject);
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    ListMap localListMap = (ListMap)super.clone();
    if (this.m_map != null)
      localListMap.m_map = ((HashMap)this.m_map.clone());
    if (this.m_list != null)
      localListMap.m_list = ((ListSet)this.m_list.clone());
    localListMap.m_keySet = null;
    localListMap.m_entrySet = null;
    localListMap.m_values = null;
    return localListMap;
  }

  private Iterator getIterator(int paramInt)
  {
    return new ListMapIterator(this, paramInt, null);
  }

  private Map.Entry getEntry(Object paramObject1, Object paramObject2)
  {
    return new ListMapEntry(this, paramObject1, paramObject2, null);
  }

  static ListSet access$500(ListMap paramListMap)
  {
    return paramListMap.m_list;
  }

  static Map.Entry access$600(ListMap paramListMap, Object paramObject1, Object paramObject2)
  {
    return paramListMap.getEntry(paramObject1, paramObject2);
  }

  static Iterator access$700(ListMap paramListMap, int paramInt)
  {
    return paramListMap.getIterator(paramInt);
  }

  private class ListMapEntry
    implements Map.Entry
  {
    Object m_key;
    Object m_value;
    private final ListMap this$0;

    private ListMapEntry(, Object paramObject1, Object paramObject2)
    {
      this.this$0 = paramListMap;
      this.m_key = null;
      this.m_value = null;
      this.m_key = paramObject1;
      this.m_value = paramObject2;
    }

    public Object getKey()
    {
      return this.m_key;
    }

    public int hashCode()
    {
      return (((this.m_key == null) ? 0 : this.m_key.hashCode()) + ((this.m_value == null) ? 0 : this.m_value.hashCode()));
    }

    public Object getValue()
    {
      return this.m_value;
    }

    public Object setValue()
    {
      throw new UnsupportedOperationException();
    }

    public boolean equals()
    {
      int i = 0;
      if (paramObject instanceof ListMapEntry)
      {
        ListMapEntry localListMapEntry = (ListMapEntry)paramObject;
        if (getKey() == null)
          if (localListMapEntry.getKey() != null)
            break label80;
        else
          if (!(getKey().equals(localListMapEntry.getKey())))
            break label80;
        if (getValue() == null)
          if (localListMapEntry.getValue() != null)
            break label80;
        label80: i = (getValue().equals(localListMapEntry.getValue())) ? 1 : 0;
      }
      return i;
    }

    ListMapEntry(, Object paramObject1, Object paramObject2, ListMap.1 param1)
    {
      this(paramListMap, paramObject1, paramObject2);
    }
  }

  private class Values extends AbstractCollection
  {
    private final ListMap this$0;

    private Values()
    {
      this.this$0 = paramListMap;
    }

    public int size()
    {
      return this.this$0.size();
    }

    public boolean contains()
    {
      return this.this$0.containsValue(paramObject);
    }

    public void clear()
    {
      this.this$0.clear();
    }

    public Iterator iterator()
    {
      return ListMap.access$700(this.this$0, 2);
    }

    Values(, ListMap.1 param1)
    {
      this(paramListMap);
    }
  }

  private class EntrySet extends AbstractSet
  {
    private final ListMap this$0;

    private EntrySet()
    {
      this.this$0 = paramListMap;
    }

    public int size()
    {
      return this.this$0.size();
    }

    public boolean contains()
    {
      boolean bool = false;
      if ((paramObject != null) && (paramObject instanceof Map.Entry))
      {
        Map.Entry localEntry = (Map.Entry)paramObject;
        Object localObject1 = localEntry.getKey();
        if (this.this$0.containsKey(localObject1))
        {
          Object localObject2 = this.this$0.get(localObject1);
          Object localObject3 = localEntry.getValue();
          bool = (localObject2 == null) ? false : (localObject3 == null) ? true : localObject2.equals(localObject3);
        }
      }
      return bool;
    }

    public boolean remove()
    {
      int i = 0;
      if ((paramObject != null) && (paramObject instanceof Map.Entry))
      {
        Map.Entry localEntry = (Map.Entry)paramObject;
        Object localObject = localEntry.getKey();
        int j = size();
        this.this$0.remove(localObject);
        i = (j != size()) ? 1 : 0;
      }
      return i;
    }

    public void clear()
    {
      this.this$0.clear();
    }

    public Iterator iterator()
    {
      return ListMap.access$700(this.this$0, 1);
    }

    EntrySet(, ListMap.1 param1)
    {
      this(paramListMap);
    }
  }

  private class KeySet extends AbstractSet
  {
    private final ListMap this$0;

    private KeySet()
    {
      this.this$0 = paramListMap;
    }

    public int size()
    {
      return this.this$0.size();
    }

    public boolean contains()
    {
      return this.this$0.containsKey(paramObject);
    }

    public boolean remove()
    {
      int i = size();
      this.this$0.remove(paramObject);
      return (size() != i);
    }

    public void clear()
    {
      this.this$0.clear();
    }

    public Iterator iterator()
    {
      return ListMap.access$700(this.this$0, 0);
    }

    KeySet(, ListMap.1 param1)
    {
      this(paramListMap);
    }
  }

  private class ListMapIterator
    implements Iterator
  {
    private Iterator m_iterator;
    private int m_type;
    private Object m_lastReturned;
    private final ListMap this$0;

    private ListMapIterator(, int paramInt)
    {
      this.this$0 = paramListMap;
      this.m_iterator = null;
      this.m_lastReturned = null;
      this.m_type = paramInt;
      this.m_iterator = ListMap.access$500(paramListMap).iterator();
    }

    public boolean hasNext()
    {
      return this.m_iterator.hasNext();
    }

    public Object next()
    {
      this.m_lastReturned = this.m_iterator.next();
      Object localObject1 = null;
      switch (this.m_type)
      {
      case 0:
        localObject1 = this.m_lastReturned;
        break;
      case 1:
        Object localObject2 = this.this$0.get(this.m_lastReturned);
        localObject1 = ListMap.access$600(this.this$0, this.m_lastReturned, localObject2);
        break;
      case 2:
        localObject1 = this.this$0.get(this.m_lastReturned);
      }
      return localObject1;
    }

    public void remove()
    {
      this.m_iterator.remove();
      this.this$0.remove(this.m_lastReturned);
    }

    ListMapIterator(, int paramInt, ListMap.1 param1)
    {
      this(paramListMap, paramInt);
    }
  }
}